package com.sx.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.dbutils.handlers.MapListHandler;

import com.annotation.BaseService;

import net.sf.ehcache.search.expression.And;

public class TempSearchService {
	/**
	 * 普通查询
	 * @param request
	 * @return
	 * @throws SQLException
	 */
	public  List<Object>  ordinaryList(HttpServletRequest request) throws SQLException {
		
		String city = request.getParameter("city");
		String sql="select City,Cnty,Town,station_name,Datetime,PRS,TEM,RHU,PRE_24h,PRE,VIS from cmiss_all_position_hours where city like '%"+city+"%' order by datetime desc";
		List<Object> list = new ArrayList<>();
    	list.add(BaseService.queryList(sql, null));
    	
		return list;
	} 
	/**
	 * 高级查询
	 * @param request
	 * @return
	 * @throws SQLException
	 */
	public  List<Object>  seniorDetails(HttpServletRequest request) throws SQLException {
			String time=request.getParameter("times");
			String city=request.getParameter("city");
			String cnty=request.getParameter("cnty"); 
			String sql="select City,Cnty,Town,station_name,Datetime,PRS,TEM,RHU,PRE_24h,PRE,VIS from cmiss_all_position_hours where city like '%"+city+"%' And  cnty like '%"+cnty+"%' And Datetime=date_add('"+time+"', interval -8 hour)"  ;
			
//			System.out.println(sql);
			List<Object> list = new ArrayList<>();
	    	list.add(BaseService.queryList(sql, null));
			return list;
		} 
        
	
	/**
	 * 自定义检索
	 * @param request
	 * @return
	 * @throws SQLException
	 */
		public  List<Object>  customSearch(HttpServletRequest request) throws SQLException {
		String  positionname=request.getParameter("position");
		String sql="select station_name,City,Cnty,Town,Datetime,PRS,TEM,RHU,PRE_24h,PRE,VIS from cmiss_all_position_hours where Town like '%"+positionname+"%'  order by datetime desc ";
		List<Object> list = new ArrayList<>();
    	list.add(BaseService.queryList(sql, null));
		return list;
	}
	
}
